<?php 
/*
 * Save the Person's (student or faculty details into database & redirect to DisplayPage with 
 * a new variable called shwetha_result.
 * */
session_start();


$courseId= $_POST["cId"];
$coursename= $_POST["CName"];
$courseNumber= $_POST["CNumber"];

// DB connect
require "config.php";
$con = mysql_connect("localhost",$db_user ,$db_pass);
if (!$con){
	$_SESSION["shwetha_result"] = "Database cannot connect. Changes not saved.";
	header('Location: UpdateCourse.php');
}
mysql_select_db($db_name, $con);


// Update Course
$format = "update course set courseName = '%s', courseNumber  = '%s' where (courseId = \"%s\")";
$query = sprintf($format, $coursename, $courseNumber, $courseId);

//$_SESSION["shwetha_result"] = $coursename." ".$courseNumber;
$q_result = mysql_query($query);
if( !$q_result )
{
	//$_SESSION["shwetha_result"] = "Changes cannot be saved DB course table update error";
	echo "Changes cannot be saved DB course table update error";
	header('Location:  UpdateCourse.php');
}


//$_SESSION["shwetha_result"] = "Successfully Saved !!";
//$_SESSION["shwetha_result"] = $query;
header('Location: UpdateCourse.php');

?>